﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using 纸片人.AttributeUsageFloder;

// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“空白页”项模板

namespace 纸片人.PageViews
{
    [PageTypeAttribute("cpu","亮度饱和度对比度")]
    /// <summary>
    /// 可用于自身或导航至 Frame 内部的空白页。
    /// </summary>
    public sealed partial class BrightnessSaturationContrastPage : Page
    {
        int width;
        int height;
        Color[] colors;

        public BrightnessSaturationContrastPage()
        {
            this.InitializeComponent();
        }

        private void brightness_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
        {
            //计算亮度
            var brightnessColors = PictureFilter.BrightnessEffect(colors, width, height, brightness.Value/100);
            var saturationColors = PictureFilter.SaturationEffect(brightnessColors, width, height, Saturation.Value/100);
            var contrast = PictureFilter.ContrastEffect(saturationColors, width, height, Contrast.Value/100);

            Function.InitialImage(saturationColors, width, height, image);


        }

        /// <summary>
        /// 选择图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void selectPicture_Click(object sender, RoutedEventArgs e)
        {
            var cBitmap = await Function.SelectImageAsync();
            
            Function.InitialImage(cBitmap, out width, out height, out colors);
        }

        private void resetPicture_Click(object sender, RoutedEventArgs e)
        {

        }
    }
}
